package socket;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class ClientDemo1 implements Runnable {
	@Override
	public void run() {
		try {
			Socket socket = new Socket("192.168.1.104", 8899);
			System.out.println("连上服务器!");
			Scanner in = new Scanner(System.in);
			String message;			
			ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
			do {
				message = in.nextLine();
				out.writeObject(message);
				out.flush();
			} while (!message.equals("bye"));

			in.close();
			socket.close();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
